package pub.tbc.api.config;

import pub.tbc.toolkit.CastUtil;
import pub.tbc.toolkit.Objs;
import pub.tbc.toolkit.PropsUtil;

import java.util.Properties;

/**
 * 项目通用配置
 *
 * @author tbc on 2017/3/2.
 */
public class ProjectConfig {
    //    private ApplicationConfig config = ConfigFactory.getApplicationConfig();
//    private ApplicationConfig config = new ApplicationConfig();
    private Properties config = PropsUtil.load("application.properties");

    private static ProjectConfig instance = new ProjectConfig();

    public static ProjectConfig instance() {
        if (instance == null) {
            // TODO ...
        }
        return instance;
    }

    public boolean printBanner() {
        return CastUtil.castBoolean(PropsUtil.getString(config, "banner.print"), true);
    }

    public String httpHost() {

        return PropsUtil.getString(config, "http.host");
    }

    public int httpPort() {
        return PropsUtil.getInt(config, "http.port");
    }

    public String invoker() {
        String value = PropsUtil.getString(config, "invoker.type");
        return Objs.isEmpty(value) ? DefaultConfig.INVOKER_TYPE : value;
    }


}
